﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;
using DTO;
using System.Collections;
using System.Runtime.InteropServices;
namespace BLL
{
    public class BangBLL
    {
        QuanLyDiemDataContext DB = new QuanLyDiemDataContext();
        public IQueryable SelectDes()
        {
            //var hdn = from h in DB.CanBos
            //          join n in DB.ChucVus 
            //          on h.MaChucVu equals n.MaChucVu into gs
            //          from g in gs.DefaultIfEmpty()
            //          select new
            //          {
            //              MaCanBo = h.MaCanBo,
            //              HoTen = h.HoTen,
            //              TenChucVu = g.TenChucVu
            //          };
            //return hdn.OrderByDescending(s => s.MaCanBo).AsQueryable();
            var list = from p in DB.CanBos
                       join n in DB.ChucVus
                       on p.MaChucVu equals n.MaChucVu into gs
                       from g in gs.DefaultIfEmpty()
                       where !(from h in DB.Users select h.MaCanBo).Contains(p.MaCanBo)
                       select new
                       {
                           p.MaCanBo,
                           p.HoTen,
                           g.TenChucVu
                       };
            return list.AsQueryable();
            //return DB.CanBos.Join(
            //    DB.ChucVus,
            //    a => a.MaChucVu,
            //    b => b.MaChucVu,
            //    (a, b) => new
            //    {
            //        a.MaCanBo,
            //        a.HoTen,
            //        b.TenChucVu
            //    }
            //    ).Where(s => !(from p in DB.Users select p.MaCanBo).Contains(s.MaCanBo)).AsQueryable();
        }
    }
}
